<template>
  <div class="rankingBox">
    <div class="rankingTop">
      <div class="rankingTop-tit">
        <div class="rankingTop-tit-left">
          <router-link
            tag="span"
            class="iconfont icon-arrow-left-bold"
            :to="'/home'"
          ></router-link
          >排行榜
        </div>
        <div></div>
      </div>
    </div>
    <!-- 内容 -->
    <van-tabs
      class="my-van"
      v-model="active"
      scrollspy
      sticky
      offset-top="40px"
      background="#e3e9f5"
      color="rgba(255, 58, 52, 0.7)"
      line-height="6px"
      title-active-color="#1b1f2d"
    >
      <div class="rankingContent">
        <!-- <div class="rankingTop-bar">
                    <ul> -->
        <!-- 分类栏 -->
        <!-- <li :class="[{ active: rankingIndex == index }]" @click="rankingFun(index)" v-for="(item, index) in rankingListBar" :key="index">{{ item }}</li> -->
        <!-- </ul>
                </div> -->
        <div class="top">
          <h2 class="text">榜单推荐</h2>
        </div>
        <div class="threeContent">
          <ul>
            <li>
              <p>编辑推荐榜</p>
              <p>每月更新</p>
            </li>
            <router-link tag="li" :to="'/songList?id=991319590'">
              <p>说唱榜</p>
              <p>每周五更新</p>
            </router-link>
            <router-link tag="li" :to="'/songList?id=5059661515'">
              <p>民谣榜</p>
              <p>每周五更新</p>
            </router-link>
          </ul>
        </div>
        <van-tab
          v-for="item in rankingListBar.slice(0, 1)"
          :title="item"
          :key="item"
        >
          <!-- 官方榜 -->
          <div class="official-tit">
            <span class="iconfont icon-yinle1"></span>
            {{ item }}榜
          </div>

          <!-- 各种榜单 -->
          <div class="allKinds">
            <router-link
              class="kinds1"
              tag="div"
              v-for="(item1, index1) in listName"
              :key="index1"
              :to="'/songList?id=' + item1.id"
            >
              <div class="top-tit">
                <span>{{ item1.name }}</span>
                <span>每天更新</span>
              </div>
              <div class="kindContent">
                <div class="left">
                  <div class="img">
                    <img class="bigImg" :src="coverImgUrlList[index1]" alt="" />
                    <img
                      class="middleImg"
                      :src="coverImgUrlList[index1]"
                      alt=""
                    />
                    <img
                      class="miniImg"
                      :src="coverImgUrlList[index1]"
                      alt=""
                    />
                  </div>
                  <div class="left-list">
                    <ul>
                      <li
                        v-for="(item2, index2) in kindContentList[index1]"
                        :key="item2.id"
                      >
                        <span>{{ index2 + 1 }}</span>
                        <p>
                          {{ item2.name }}<span>-{{ item2.ar[0].name }}</span>
                        </p>
                        <span>{{ listName[index1].str }}</span>
                      </li>
                    </ul>
                  </div>
                </div>
              </div>
            </router-link>
          </div>
        </van-tab>
        <van-tab
          v-for="(item, index) in rankingListBar.slice(1, 6)"
          :title="item"
          :key="index + item"
        >
          <!-- 精选榜--曲风榜等等 -->
          <div class="styleList">
            <div class="tit">{{ item }}榜</div>
            <div class="styleBox">
              <ul>
                <li>
                  <p>编辑推荐榜</p>
                  <p>每月更新</p>
                </li>
                <li>
                  <p>编辑推荐榜</p>
                  <p>每月更新</p>
                </li>
                <li>
                  <p>说唱榜</p>
                  <p>每周五更新</p>
                </li>
                <li>
                  <p>民谣榜</p>
                  <p>每周五更新</p>
                </li>
              </ul>
            </div>
          </div>
        </van-tab>
      </div>
    </van-tabs>
  </div>
</template>

<script>
import { getPlaylistDetails } from "../api/song";
export default {
  data() {
    return {
      rankingIndex: 0,
      rankingListBar: ["官方", "精选", "曲风", "全球", "语种", "MV", "特色"], // 目录
      listName: [
        { name: "飙升榜", id: 19723756, str: "↑" },
        { name: "新歌榜", id: 3779629, str: "新" },
        { name: "热歌榜", id: 3778678, str: "热" },
        { name: "原创榜", id: 2884035, str: "-" },
      ], // 榜单名
      active: 2,
      kindContentList: [],
      coverImgUrlList: [],
    };
  },
  methods: {
    rankingFun(index) {
      this.rankingIndex = index;
      // this.getBoutiqueListFun();
    },
    getPlaylistDetailFun() {
      for (let i = 0; i < this.listName.length; i++) {
        getPlaylistDetails({ id: this.listName[i].id }).then((data) => {
          this.coverImgUrlList.push(data.playlist.coverImgUrl);
          this.kindContentList.push(data.playlist.tracks.splice(0, 3));
        });
      }
    },
  },
  created() {
    this.rankingFun();
    this.getPlaylistDetailFun();
  },
};
</script>

<style lang="less" >
.rankingBox {
  background-image: linear-gradient(#e3e9f5, #f8f9fd);
  /deep/ .van-tabs__line {
    bottom: 28px;
    // background: rgba(255, 58, 52, 0.8);
  }
  .rankingTop {
    width: 100%;
    position: fixed;
    z-index: 500;
    top: 0;
    left: 0;
    padding-left: 16px;
    font-size: 20px;
    background-image: linear-gradient(#e3e9f5, #e3e9f5);
    height: 48px;
    .rankingTop-tit {
      height: 48px;
      line-height: 48px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .rankingTop-tit-left {
        span {
          font-size: 20px;
          margin-right: 10px;
        }
        .left {
          font-size: 25px;
          margin-right: 12px;
        }
      }
    }
  }
  .rankingContent {
    .rankingTop-bar {
      padding: 0 16px;
      position: fixed;
      z-index: 500;

      top: 47px;
      left: 0;
      // margin-top: 48px;
      height: 37px;
      line-height: 37px;
      width: 100%;
      background: #e3e9f5;
      ul::-webkit-scrollbar {
        display: none;
      }
      ul {
        overflow: auto;
        display: flex;
        height: 40px;
        li {
          font-size: 14px;
          flex-shrink: 0;
          padding: 0 3px;
          color: #555555;
          margin-right: 28px;
          &.active {
            color: #060606;
            position: relative;
            &::after {
              position: absolute;
              left: 0px;
              bottom: 10px;
              content: "";
              display: inline-block;
              width: 100%;
              height: 7px;
              background: rgba(211, 14, 14, 0.5);
              border-radius: 3px;
            }
          }
        }
      }
    }
    .top {
      margin: 0 16px;

      margin-top: 50px;
      .text {
        height: 40px;
        line-height: 40px;
        font-size: 20px;
      }
    }
    .threeContent {
      margin: 0 16px;

      ul {
        display: flex;
        justify-content: space-between;
        li {
          box-sizing: border-box;
          width: 108px;
          height: 108px;
          background: #000;
          color: white;
          text-align: center;
          border-radius: 8px;
          &:nth-of-type(1) {
            background: #7c9ccf;
          }
          &:nth-of-type(2) {
            background: #747ba7;
          }
          &:nth-of-type(3) {
            background: #8f9d84;
          }
          & p:first-child {
            display: inline-block;
            margin-top: 26px;
            font-size: 16px;
            height: 28px;
            line-height: 28px;
            border-bottom: 1px solid white;
          }
          & p:nth-of-type(2) {
            height: 22px;
            line-height: 22px;
            font-size: 12px;
          }
        }
      }
    }
    .official-tit {
      padding: 0 16px;

      height: 56px;
      font-size: 19px;
      vertical-align: bottom;
      display: table-cell;
    }
    .allKinds {
      margin: 0 16px;
      margin-top: 11px;
      padding-bottom: 25px;
      .kinds1 {
        padding: 6px 17px 13px 18px;
        background: white;
        border-radius: 10px;
        margin-bottom: 15px;
        .top-tit {
          height: 46px;
          line-height: 46px;
          display: flex;
          justify-content: space-between;
          & span:first-child {
            font-size: 20px;
          }
          & :nth-of-type(2) {
            font-size: 12px;
            color: #9f9f9f;
          }
        }
        .kindContent {
          .left {
            display: flex;
            .img {
              margin-right: 15px;
              width: 82px;
              position: relative;
              .bigImg {
                z-index: 20;
                width: 66px;
                border-radius: 6px;
                position: absolute;
                top: 0;
                left: 0;
              }
              .middleImg {
                border-radius: 4px;
                width: 55px;
                position: absolute;
                top: 11px;
                left: 20px;
                z-index: 10;
                opacity: 0.2;
              }
              .miniImg {
                border-radius: 4px;
                width: 33px;
                position: absolute;
                top: 33px;
                left: 50px;
                z-index: 9;
                opacity: 0.1;
              }
            }

            .left-list {
              ul {
                li {
                  display: flex;
                  justify-content: space-between;
                  height: 17px;
                  margin-bottom: 5px;
                  align-items: center;
                  & span:first-child {
                    font-size: 12px;
                  }
                  p {
                    width: 170px;
                    font-size: 14px;
                    color: #202126;
                    margin: 0 10px;
                    span {
                      color: #4d4c54 !important;
                    }
                  }
                  & span:last-child {
                    color: #81cfb5;
                    font-size: 12px;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  .styleList {
    padding: 0 16px 28px 16px;
    .tit {
      color: #000007;
      font-size: 20px;
      height: 29px;
      line-height: 29px;
    }
    .styleBox {
      ul {
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        li {
          margin-top: 10px;
          box-sizing: border-box;
          width: 108px;
          height: 108px;
          background: #000;
          color: white;
          text-align: center;
          border-radius: 8px;
          &:nth-of-type(1) {
            background: #7c9ccf;
          }
          &:nth-of-type(2) {
            background: #747ba7;
          }
          &:nth-of-type(3) {
            background: #8f9d84;
          }
          & p:first-child {
            display: inline-block;
            margin-top: 26px;
            font-size: 16px;
            height: 28px;
            line-height: 28px;
            border-bottom: 1px solid white;
          }
          & p:nth-of-type(2) {
            height: 22px;
            line-height: 22px;
            font-size: 12px;
          }
        }
      }
    }
  }
}
</style>
